home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 4 / Gold Medal Software - Volume 4 (Gold Medal) (1994).iso / os2 / lbasic04.arj / FACTORIL.BAS < prev    next >
BASIC Source File  |  1993-11-22  |  436b  |  26 lines

  1.  
  2.     'this program computes a factorial for a keyboard entered
  3.     'number and displays the result
  4.  
  5.     input "Please enter a number>"; entry
  6.  
  7.     result = 1
  8.  
  9. [recurringLoop]
  10.  
  11.     counter = counter + 1
  12.     if counter > entry then [skip]
  13.     result = result * counter
  14.     gosub [recurringLoop]
  15.  
  16. [skip]
  17.  
  18.     entry = entry - 1
  19.     if entry = 1 then [end]
  20.     return
  21.  
  22. [end]
  23.  
  24.     print "The factorial is: "; result
  25.  
  26.